package jmind.core.spring;

import java.io.File;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.ClassPathResource;

public class LoadXML {

    public static void main(String[] args) {
        String path = System.getProperty("user.dir") + File.separator + "src" + File.separator + "main"
                + File.separator + "webapp" + File.separator + "WEB-INF" + File.separator + "spring" + File.separator
                + "jdbc-config.xml";

        System.out.println(path);

        //	AbstractXmlApplicationContext context = new FileSystemXmlApplicationContext(path);
        //	AbstractXmlApplicationContext context2 = new ClassPathXmlApplicationContext(path);
        //	DefaultListableBeanFactory xmlBeanFactory = new XmlBeanFactory(new FileSystemResource(path));

        ClassPathResource res = new ClassPathResource("beans.xml");
        DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
        XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(factory);
        reader.loadBeanDefinitions(res);

    }

    public static String getRealXmlPath(String defaultXmlFileName) {

        return System.getProperty("ConifgGlobals_ROOTPATH") + (File.separator) + "XmlConfig" + File.separator + "sys"
                + (File.separator) + defaultXmlFileName;
    }

    public static String getRealSysConfigPath() {
        return System.getProperty("ConifgGlobals_ROOTPATH") + (File.separator) + "XmlConfig" + File.separator + "sys"
                + (File.separator);
    }

}
